package com.zb.vo;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.zb.entity.FieldListVo;
import com.zb.entity.ZjGoodsField;
import com.zb.entity.ZjGoodsParamField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.util.Date;

/**
 * @Author WEN
 * @Date 2023/8/2 0002
 **/
@Data
@ApiModel("商品字段列表对象")
public class GoodsFieldListVo extends FieldListVo {
    @ApiModelProperty(value = "字段ID")
    private Long id;

    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @ApiModelProperty(value = "更新时间")
    private Date updateTime;

    @ApiModelProperty(value = "单选/多选项内容")
    private String content;

    public static GoodsFieldListVo beanToVo(ZjGoodsField field, String content) {
        GoodsFieldListVo vo = new GoodsFieldListVo();
        BeanUtil.copyProperties(field, vo);
        vo.setStatus(field.getDisabled());
        vo.setCreateTime(field.getGmtCreate());
        vo.setUpdateTime(field.getGmtUpdate());
        vo.setContent(content);
        return vo;
    }

    public static GoodsFieldListVo beanToVo(ZjGoodsParamField field, String content) {
        GoodsFieldListVo vo = new GoodsFieldListVo();
        BeanUtil.copyProperties(field, vo);
        vo.setStatus(field.getDisabled());
        vo.setCreateTime(field.getGmtCreate());
        vo.setUpdateTime(field.getGmtUpdate());
        vo.setContent(content);
        return vo;
    }
}
